﻿@{
    ViewBag.Title = "AddVote";
    Layout = "~/Views/Shared/_Layout.cshtml";
}



<h2>AddVote</h2>
@model KMSFanHome2.Models.ModelList   /*投票详情表*/

@{
    //定义其他MODEL,其它models要从返回的ViewBag相应类型进行转换才可以识别
    List<KMSFanHome2.Models.count_voting> voteList = ViewBag.count_votingList as List<KMSFanHome2.Models.count_voting>;
    
      }

<h2>投票基本设置</h2>

@using (@Html.BeginForm())
{
   @Html.ValidationSummary(false)
    
    
   <fieldset>
       <div class="editor-label">投票标题：@Html.EditorFor(model=>model.vd.memo)</div>

       <div> 投票类型：&nbsp;<label for="single"> @Html.RadioButtonFor(model => model.vd.isSingle, true, new { @id="single",@name="status",@checked="checked"})单选</label></div>
      <div><label for="multi">@Html.RadioButtonFor(model => model.vd.isSingle, false, new { @id="multi",@name="status"})多选</label> </div>


       <div id="voteMain">
           <div>投票选项：</div>


               @for(int i=0;i<2;i++)
               {
                    <div class="voteItem">第 @i 项： @Html.EditorFor(m=>Model.cv[i].selectname)</div>
           
               }
 
       </div>
       <div><input type="button" value="增加选项"  onclick="addItem()"/></div>

       <div><input type="submit" value="提交" /></div>
   </fieldset>


}


<script type="text/javascript">
    function addItem() {

        var length= $(".voteItem").length;
        //$("#voteMain").append($(".voteItem").html()+"<br />"); /*追加HTML*/

        //由html.editfor演变而来
        $("#voteMain").append('<div class="voteItem">第'+ length +"项："+' <input class="text-box single-line" id="cv_'+length+'__selectname" name="cv['+length+'].selectname" type="text">');
    }

</script>